package com.blb.zy_community.utils;

import eu.bitwalker.useragentutils.Browser;
import eu.bitwalker.useragentutils.OperatingSystem;
import eu.bitwalker.useragentutils.UserAgent;

public class UserAgentUtil {
    /**
     * 获取浏览器类型
     */
    public static String getBrowser(String agent) {
        UserAgent userAgent = UserAgent.parseUserAgentString(agent);
        Browser browser = userAgent.getBrowser();
        if (browser == null) {
            return "未知";
        }
        return browser.getName();
    }

    /**
     * 获取操作系统
     */
    public static String getOs(String agent) {
        UserAgent userAgent = UserAgent.parseUserAgentString(agent);
        OperatingSystem os = userAgent.getOperatingSystem();
        if (os == null) {
            return "未知";
        }
        return os.getName();
    }
}